package com.miya.demo.support.rabbitmq.logrecord;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

public class LogRecordConfig {

    public static final String QUEUE = "logRecord";

    public static final String EXCHANGE = "logRecord";

    public static final String ROUTING_KEY = "logRecord";

    @Bean("logRecordExchange")
    public Exchange logRecordExchange() {
        return ExchangeBuilder.topicExchange(LogRecordConfig.EXCHANGE).durable(true).build();
    }

    @Bean("logRecordQueue")
    public Queue logRecordQueue() {
        return new Queue(LogRecordConfig.QUEUE, true, false, false);
    }

    @Bean
    public Binding logRecordQueueBingding(@Qualifier("logRecordQueue") Queue queue, @Qualifier("logRecordExchange") Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(LogRecordConfig.ROUTING_KEY).noargs();
    }
}
